#include<bits/stdc++.h>
using namespace std;

int sum = 0;
string s;
int k;
char c1,c2;

int main()
{
	cin>>k>>s>>c1>>c2;
	long long ans = 0;
	for(int i = k-1,j = 0;i<s.size();i++,j++)
	{
		if(s[j]==c1)
		sum++;
		if(s[i]==c2)
		ans+=sum;	
			
	}
	cout<<ans<<endl;
	return 0;	
} 
